package cn.apotato.inclusion.commin;


import cn.apotato.inclusion.commin.response.ResponseCode;

/**
 * @author xphu
 * @version 1.0
 * @date 2021/8/10 11:09
 */
public class EnumUtil {

    public static <T extends ResponseCode> String getMsgByCode(Integer code, Class<T> t){
        for(T item: t.getEnumConstants()){
            if(code.equals(item.code)){
                return item.message;
            }
        }
        return "";
    }

    public static <T extends ResponseCode> Integer getCodeByMsg(String msg, Class<T> t){
        for(T item: t.getEnumConstants()){
            if(msg.equals(item.message)){
                return item.code;
            }
        }
        return 500;
    }
}
